#pragma once

#include <guiframe/IModule.h>
#include <qbnet/include/network_service.h>

class CefViewDelegate;

class QbBondModule : public IModule,
                     public CUnknownObject<INetworkEventObserver> {
 public:
  static QbBondModule& instance();
  IApplication* app() const { return m_app; }

  bool showWebPage(const QString& url);

 protected:
  // 通过 IModule 继承
  void initialize(IApplication* app) override;
  void unInitialize() override;
  int execCommand(CmdInfo ci) const override;
  bool closeCommandWindow(int cmdId, QWidget* widget) override;
  void requestBondData();
  void registNetEvent();
  void unRegistNetEvent();

  // INetworkEventObserver
  STDMETHOD_(void, OnForceQuit)(THIS_ int32_t connect_id) {}
  STDMETHOD_(void, OnDisConnect)(THIS_ int32_t connect_id) {}
  STDMETHOD_(void, OnRecover)(THIS_ int32_t connect_id);

 private:
  QbBondModule() = default;

 private:
  IApplication* m_app = nullptr;

  QSharedPointer<CefViewDelegate> m_pCefViewDelegate;
};
